<%--
  Created by IntelliJ IDEA.
  User: 23301
  Date: 2020/6/23
  Time: 18:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <title>Title</title>
</head>
<body>

    <button onclick="ajax()">查询</button>
    <table class="table" >
        <tr id="trOne">
            <th>id</th>
            <th>name</th>
            <th>pwd</th>
        </tr>
    </table>
    <script type="text/javascript" src="js/jquery-1.12.4.js"></script>
    <script type="text/javascript">
        function ajax(){
            $('.clear').remove();
            $.ajax({
                "url" : "StudentServlet?path=index",
                "type" : "get",
                "dataType" : "json",
                "success" : function(data){
                    var item;
                    $.each(data,function(i,result){
                        item= "<tr class='clear'><td>"+result['id']+"</td><td>"+result['name']+"</td><td>"+result['pwd']+"</td></tr>";
                        $('.table').append(item);
                    }); 
                }
            });
        }
    </script>
</body>
</html>
